package edu.sctu.nieyu.day20150606.trainsystem;

/**
 * Created by user01 on 2015/6/6.
 */
public class TrainCheck {

    private String emergency = "火灾，暴恐，人员伤亡";
    private Train train;

    public TrainCheck(Train train){
        this.train = train;
    }

    /**
     * 判断有无紧急情况
     * @return
     */

    public boolean observeTrain(){
        boolean is_emergency = false;
        if (train.isIs_emergency()){
            if (emergency.contains(train.getEmergencyName())){
                is_emergency = true;
            }
        }else {
            is_emergency = false;
        }
        return is_emergency;
    }

    /**
     * 控制中心发出通知，处理紧急情况
     */
    public void controlCenter(){

        if (train.isIs_emergency()){
            if (new TrainCheck(train).observeTrain()){
                System.out.println("地铁发生紧急情况，请各部门立即行动，停止列车，疏散乘客！！");
            }else {
                System.out.println("请列车安检员前往处理事故！");
            }
        }
    }
}
